package tmall.portal.mapper;

import org.apache.ibatis.annotations.*;
import tmall.framework.eobj.SegmentEobj;
import tmall.portal.eobj.RoleEobj;
import tmall.portal.eobj.UserEobj;

@Mapper
public interface RoleMapper {



    @Select("SELECT user_id, username, password,status, email,createTms,phone_number FROM tmall_user where username = #{username}")
    @Results(value = {
            @Result(column = "user_id", property = "userId"),
            @Result(column = "username", property = "username"),
            @Result(column = "password", property = "password"),
            @Result(column = "status", property = "status"),
            @Result(column = "email", property = "email"),
            @Result(column = "createTms", property = "createTms"),
            @Result(column = "phone_number", property = "phoneNumber")

    })
    public RoleEobj queryRoleById(@Param("username") String username);

    @Insert("INSERT INTO tmall_id_config (name, max_id, step,description, update_time) VALUES ( #{name}, #{maxId}, #{step}, #{description},#{updateTime})")
    public int addRole(RoleEobj input);

    @Update("UPDATE tmall_id_config SET max_id = max_id + step WHERE name = #{tag}")
    public int updateRole(RoleEobj input);

    @Select("SELECT name, max_id, step,description, update_time FROM tmall_id_config where name =  #{tag}")
    @Results(value = {
            @Result(column = "name", property = "name"),
            @Result(column = "max_id", property = "maxId"),
            @Result(column = "step", property = "step"),
            @Result(column = "description", property = "description"),
            @Result(column = "update_time", property = "updateTime")

    })
    public RoleEobj getSegmentByKey(@Param("tag") String input);

    @Update("UPDATE tmall_id_config SET max_id = max_id + step,SET step = #{step},description = #{description}, update_time = #{updateTime} WHERE name = #{name}")
    public int updateSegmentByKey(SegmentEobj input);

}
